﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.Extension;
using UnityEditor.UI;
using System;
using System.Extension;
using System.Reflection.Extension;
using System.Reflection;

[CustomEditor(typeof(SubjectiveToggle)) ]
public class SubjectiveToggleInspector : ToggleEditor
{
    SerializedProperty subjects;
    protected override void OnEnable()
    {
        base.OnEnable();
        subjects = serializedObject.FindProperty("m_subjects");
    }

    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        serializedObject.Update();
        subjects.ForEachItem("Commands", s =>
        {
            EditorGUILayout.PropertyField(s);
            return GUILayout.Button("Delete", EditorStyles.miniButton);
        });
        serializedObject.ApplyModifiedProperties();
    }

    [MenuItem("GameObject/UI/Subjective/Toggle")]
    static void CreateSubjectiveText()
    {
        List<GameObject> newObjects = GameObjectMenu.CreateNewControlInHierarchy("Toggle", typeof(CanvasRenderer), typeof(SubjectiveToggle));

        newObjects.ForEach(o =>
        {
            //SubjectiveButton button = o.GetComponent<SubjectiveButton>();
            //SubjectiveImage image = o.GetComponent<SubjectiveImage>();
            //button.targetGraphic = image;
            //SubjectiveTextInspector.CreateNewObject(o, "Text", typeof(SubjectiveText));
        });

    }
}
